home *** CD-ROM | disk | FTP | other *** search
/ Resource Library: Multimedia / Resource Library: Multimedia.iso / maestro / source / displytl / imageio.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-15  |  2.7 KB  |  94 lines

  1. /*
  2.  * Copyright (c) 1990, 1991 Stanford University
  3.  *
  4.  * Permission to use, copy, modify, and distribute this software and 
  5.  * its documentation for any purpose is hereby granted without fee, provided
  6.  * that (i) the above copyright notices and this permission notice appear in
  7.  * all copies of the software and related documentation, and (ii) the name
  8.  * Stanford may not be used in any advertising or publicity relating to
  9.  * the software without the specific, prior written permission of
  10.  * Stanford.
  11.  * 
  12.  * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 
  13.  * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 
  14.  * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  
  15.  *
  16.  * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
  17.  * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES
  18.  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT
  19.  * ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY,
  20.  * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  21.  * SOFTWARE.
  22.  */
  23. /* $Header $ */
  24. /* $Log $ */
  25. static char imageiorcsid[] = "$Header: /Source/Media/collab/DisplayTool/RCS/imageio.c,v 1.2 92/10/29 13:57:50 drapeau Exp Locker: drapeau $";
  26.  
  27. #include <stdio.h>
  28. #include <sys/types.h>
  29. #include <sys/uio.h>
  30. #include <fcntl.h>
  31. #include <xview/xview.h>
  32. #include <xview/panel.h>
  33. #include <xview/frame.h>
  34. #include <xview/svrimage.h>
  35. #include <xview/icon.h>
  36. #include <xview/notify.h>
  37. #include <Sender.h>
  38. #include <Receiver.h>
  39. #include "xvimage.h"
  40.  
  41. #define IconX 64
  42. #define IconY 64
  43. #define Depth 8
  44. #define Permissions 0666
  45.  
  46. char *FilenameToFileData(filename, length)
  47. char *filename;
  48. int *length;
  49. {
  50.   FILE *fp;
  51.   char *fileData;
  52.   if ((fp=fopen(filename, "r"))==NULL)
  53.     {
  54.       printf("Can't open %s for reading\n", filename);
  55.       return 0;
  56.     }
  57.  /* find the size of the file */
  58.   fseek(fp, 0L, 2);
  59.   *length = ftell(fp);
  60.   fseek(fp, 0L, 0);
  61.   fileData = (char *)malloc(*length);
  62.   if (fread(fileData, *length, 1, fp) != 1) 
  63.     {
  64.       printf("Can't read %s\n", filename);
  65.       *length = 0;
  66.       fclose(fp);
  67.       return NULL;
  68.     }
  69.   fclose(fp);
  70.   return fileData;
  71. }
  72.   
  73.  
  74. void
  75.   CreateIcon(Xv_opaque owner, char *iconFile, IconData *iconData)
  76. {
  77.   Display*        rootDpy = (Display *)XOpenDisplay(NULL);
  78.   Server_image        iconImage;
  79.   static unsigned short    window1_bits[] = {
  80. #include "DisplayTool.icon"
  81.   };
  82.   
  83.   iconImage = (Server_image)xv_create(XV_NULL, SERVER_IMAGE,
  84.                       SERVER_IMAGE_BITS, window1_bits,
  85.                       XV_WIDTH, IconX,
  86.                       XV_HEIGHT, IconY,
  87.                       SERVER_IMAGE_DEPTH, 1,
  88.                       NULL); 
  89.   xv_set(owner, FRAME_ICON,
  90.      (Icon)xv_create(XV_NULL, ICON, 
  91.              ICON_IMAGE, iconImage, NULL), NULL); 
  92.   return;
  93. }                                    /* end function CreateIcon */
  94.